import java.util.*;
public class Main{
    public int pivotInteger(int n) {
        int m1=0,m2=0;
        int max= (1+n)*n/2;
        int i=0;
        if(n==1){
            return 1;
        }
        if(n==2){
            return -1;
        }else{
            for(i=1;i<n;i++){
                m1= (1+i)*i/2;
                System.out.println("m1="+m1);
                m2=max-m1+i;
                System.out.println("m2="+m2);
                if(m1==m2){
                    return i;
                }
                if(m1>m2){
                    return -1;
                }
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n=sc.nextInt();
        //System.out.println(n+"123");
        Main m1= new Main();
        System.out.println(m1.pivotInteger(n));
    }
}